package com.qyhl.webtv.module_news.news.smallvideo.homelist;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.news.CatchSmallBean;
import com.qyhl.webtv.module_news.common.NewsUrl;
import com.qyhl.webtv.module_news.utils.NewsConstant;

import java.util.List;

/**
 * Created by qyhl on 2018/4/24.
 */

public class SmallVideoListModel implements SmallVideoListContract.SmallViddeoListModel {
    private SmallVideoListPresenter mPresenter;

    public SmallVideoListModel(SmallVideoListPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getVideoList(String newsId) {

        EasyHttp.get(NewsUrl.GET_SMALL_VIDEO_LIST)
                .params("newsId",newsId)
                .params("secId", "0")
                .execute(new SimpleCallBack<List<CatchSmallBean.NewsDetail>>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError("暂无更多内容！");
                    }

                    @Override
                    public void onSuccess(List<CatchSmallBean.NewsDetail> newsDetails) {
                        mPresenter.setVideoList(newsDetails);
                    }
                });

    }

    /**
     * 点击量统计
     * @param newsId
     */
    @Override
    public void count(String newsId) {
        EasyHttp.get(NewsUrl.GET_CATCH_NEWS_COUNT)
                .params("siteId", NewsConstant.OWNER_SITE_ID + "")
                .params("newsId", newsId)
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {

                    }

                    @Override
                    public void onSuccess(String s) {

                    }
                });

    }
}
